package com.example.infrastructure.domain.organization.aggregate;

import lombok.Getter;
import lombok.Setter;

import java.util.Objects;
import java.util.Set;

/**
 * TODO
 *
 * @author lxh
 * @date 2020/11/17 下午1:25
 **/
@Getter
@Setter
public class Organization {
    private String orgId;
    private String orgName;
    private Organization parent;
    private Set<Organization> children;

    public static Organization create() {
        return new Organization();
    }

    public static Organization createByOrgId(String orgId) {
        Organization organization = new Organization();
        organization.setOrgId(orgId);
        return organization;
    }

    public static Organization createByOrgName(String orgName) {
        Organization organization = new Organization();
        organization.setOrgName(orgName);
        return organization;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Organization that = (Organization) o;
        return orgId.equals(that.orgId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orgId);
    }
}
